const qs = require('querystring')

const bodyParse = (req, res, next) => {
  let str = ''
  // 监听req.on事件
  req.on('data', (chunk) => {
    str += chunk
  })
  req.on('end', () => {
    const body = qs.parse(str)
    req.body = body
  })
  next()
}

module.exports = bodyParse
